/**
  ******************************************************************************
  * @file    bsp_i2c.h
  * @author  Iron
  * @date    2018-08-29
  * @version v1.0
  * @brief   bsp_i2c header file
  */

#ifndef __BSP_I2C_H
#define __BSP_I2C_H

#ifdef __cplusplus
extern "C" {
#endif

/* includes ------------------------------------------------------------------*/
#include <stdint.h>

/* exported types ------------------------------------------------------------*/
/* exported constants --------------------------------------------------------*/
/* exported macro ------------------------------------------------------------*/
#define BSP_I2C_FLASE         0
#define BSP_I2C_TRUE          1

#define BSP_I2C_NO_ERR        0
#define BSP_I2C_ERR          (-1)
#define BSP_I2C_TIMEOUT      (-2)

#define BSP_I2C_MEMADD_8BIT   0
#define BSP_I2C_MEMADD_16BIT  1

/* exported functions ------------------------------------------------------- */
int32_t bsp_i2c_init(void);
int32_t bsp_i2c_write(uint8_t dev_addr, uint8_t *data, uint16_t len, uint32_t timeout);
int32_t bsp_i2c_read(uint8_t dev_addr, uint8_t *buf, uint16_t len, uint32_t timeout);

int32_t bsp_i2c_mem_page_write(uint8_t dev_addr, uint16_t mem_addr, uint16_t page_size,
                               uint16_t mem_addr_bits, uint8_t *data, uint16_t len, uint32_t timeout);

int32_t bsp_i2c_mem_write(uint8_t dev_addr, uint16_t mem_addr, uint16_t mem_addr_bits,
                          uint8_t *data, uint16_t len, uint32_t timeout);

int32_t bsp_i2c_mem_read(uint8_t dev_addr, uint16_t mem_addr, uint16_t mem_addr_bits,
                         uint8_t *buf, uint16_t len, uint32_t timeout);

/**
  * @}
  */

#ifdef __cplusplus
}
#endif

#endif /* __BSP_I2C_H */

/******************* (C)COPYRIGHT 2018 ***** END OF FILE *********************/
